trigger CountNationalActivityAttendance on NationalAttendee__c (after delete) {
/*
List<NationalAttendee__c> nal=new List<NationalAttendee__c>();
List<HCPEducation__c> hcpl=new List<HCPEducation__c>();   

recordtype rt=[select id from recordtype where sobjecttype=:'NationalAttendee__c' and name=:'全国医护人员教育活动'];
 /*  if(system.trigger.isinsert){
   if(trigger.new[0].recordtypeid==rt.id){
   nal=[select id from NationalAttendee__c where IsAttended__c=:true and HCPEducation__c=:trigger.new[0].HCPEducation__c];
   hcpl=[select id from HCPEducation__c where id=:trigger.new[0].hcpeducation__c];

        if(hcpl.size() > 0){
             HCPEducation__c hcp=hcpl[0];         
             hcp.LocalActivityAttends__c=nal.size();
             update hcp;

     }
     }
   }else 
   if (system.trigger.isdelete){
   if(trigger.old.size()==1){
    for (NationalAttendee__c nat : Trigger.old)
        {
            if(nat.ownerid != UserInfo.getUserId()){
                nat.addError('您无权删除该医护人员!');
            }
        }
     nal=[select id from NationalAttendee__c where HCPEducation__c=:trigger.old[0].HCPEducation__c];
     hcpl=[select id from HCPEducation__c where id=:trigger.old[0].hcpeducation__c];
    for(nationalattendee__c na:trigger.old){
        if(na.recordtypeid==rt.id){
         nal=[select id from NationalAttendee__c where IsAttended__c=:true and HCPEducation__c=:na.HCPEducation__c];
         hcpl=[select id,localactivityattends__c from HCPEducation__c where id=:na.hcpeducation__c];
        if(hcpl[0].localactivityattends__c==1){
          hcpl[0].localactivityattends__c=0;
          update hcpl[0];
         }
         else{
         HCPEducation__c hcp=hcpl[0];
         hcp.LocalActivityAttends__c=nal.size();
         update hcp;
         }
      }
     }
    }
   } */
}